/**
 ******************************************************************************
 * @file           : main.c
 * @brief          : RTC Real-Time Clock Example
 ******************************************************************************
 */

#include "stm32f4xx.h"
#include "./BSP/RTC/bsp_rtc.h"
#include "./BSP/USART/bsp_usart.h"
#include <stdio.h>

int main(void)
{
    HAL_Init();
    SystemClock_Config();

    usart_init(115200);

    printf("RTC Real-Time Clock Example\r\n");

    rtc_init();

    RTC_DateTime_t datetime = {
        .year = 2025,
        .month = 11,
        .day = 12,
        .hour = 10,
        .minute = 30,
        .second = 0,
        .week = 3
    };

    rtc_set_datetime(&datetime);
    printf("RTC time set\r\n");

    while (1)
    {
        RTC_DateTime_t current_time;
        rtc_get_datetime(&current_time);

        printf("%04d-%02d-%02d %02d:%02d:%02d\r\n",
               current_time.year, current_time.month, current_time.day,
               current_time.hour, current_time.minute, current_time.second);

        HAL_Delay(1000);
    }
}

void SystemClock_Config(void)
{
    /* 同上 */
}
